#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"mythread.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_threadStart_clicked()
{
    if(mythread==nullptr)
    {
        mythread = new MyThread();
        QList<int> listvalue{1,5,9,10,111,222};
        mythread->SetData(listvalue);
        connect(mythread,&MyThread::curNumber,this,&MainWindow::UpdateLable);
        mythread->start();
    }
}

void MainWindow::on_pushButton_stopThread_clicked()
{
    mythread->exit();
}

void MainWindow::UpdateLable(int id)
{
    ui->label->setText(QString::number(id));
}

void MainWindow::setdata(QList<int> data)
{
    listdata =data  ;
}
